#include <random>
#include <sstream> // For std::stringstream

#ifndef _KEY_GENERATOR_HPP_
#define _KEY_GENERATOR_HPP_

namespace alexcr4ckpentest
{
  class KeyGenerator final
  {
  public:
    ~KeyGenerator() = default;
    explicit KeyGenerator() noexcept;

    KeyGenerator(const KeyGenerator&) = delete;
    KeyGenerator(KeyGenerator&&) = delete;
    KeyGenerator& operator=(const KeyGenerator&) = delete;
    KeyGenerator& operator=(KeyGenerator&&) = delete;

    auto generate(uint8_t key_length, uint8_t salt_length) noexcept
    {
      const auto generate_one_key{[this](uint8_t length)
      {
        buffer.str("");
        for (uint8_t i{0}; i < length; i++)
        {
          buffer << get_rand_int(mt);
        }
        return std::stoul(buffer.str());
      }};

      return std::make_pair(generate_one_key(key_length), generate_one_key(salt_length));
    }

  private:
    std::random_device rand_device;
    std::mt19937 mt;
    std::uniform_int_distribution<> get_rand_int;
    std::stringstream buffer;

    uint64_t generate_one_key(uint8_t key_length);
  };
}

#endif // _KEY_GENERATOR_HPP_
